//
//  CustomViewButton.m
//  代号：47
//
//  Created by 杨佩璋 on 15/7/9.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "CustomViewButton.h"

@implementation CustomViewButton

- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image title:(NSString *)title{
    if (self = [super initWithFrame:frame]) {
        
        CGFloat width = frame.size.width;
        CGFloat height = frame.size.height;
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, 0.7*height)];
        imageView.image = image;
        imageView.contentMode =  UIViewContentModeScaleAspectFit;
        imageView.userInteractionEnabled = YES;
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0.7*height, width, 0.3 *height)];
        label.text = title;
        label.textColor = [UIColor orangeColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [UIFont boldSystemFontOfSize:17];
        label.userInteractionEnabled = YES;
        
        [self addSubview:imageView];
        [self addSubview:label];
        
        [imageView release];
        [label release];
        self.userInteractionEnabled = YES;
    }
    
    return self;
}

@end
